<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>任务大派送</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/style.css" />
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css" />
    <link rel="stylesheet" type="text/css" href="../../css/vant.css" />

    <!-- <link rel="stylesheet" href="../../css/BarlowCondensed-Bold.woff.ttf" /> -->
    <!-- <link rel="stylesheet" href="../../css/sqc.css"> -->
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        input{

            outline:none;
        }

    </style>
</head>

<body style="background:#fff">
<div id="blank" class="header" v-cloak>
    <div v-back.tapmode class="back"></div>
    <span class="title">任务大派送</span>
</div>
<div id="app" v-cloak class="task-give" style="padding-top:60px">
    <div class="task-give-top">
        <img src="../../image/task-bg-2.png" width="100%">
    </div>
    <div class="task-bottom">
        <div class="task-bottom-bg">
            <div class="task-men-header">
                <div class="task-bottom-left">
                    <p style="color: #fff">我的当前达人等级</p>
                    <p style="font-family: BarlowCondensed-Bold;font-size: 18px;color: #fff">HLv{{info_list.darenLevel}}</p>
                </div>
                <div class="task-bottom-left">
                    <div class="xiangqing">详情</div>
                </div>
            </div>
        </div>
        <div class="task-bottom-title">
            <ul>
                <li class="task-li" v-for="(list,index) in deliver_list">
                    <div style="width: 44px;height:47px;float: left;margin-right: 12px;background-repeat:no-repeat;background-size:100% 100%;" v-bind:style="getBg(list.level_task_bg)"></div>
                    <div class="task-li-right">
                        <div class="task-head">
                            <div style="font-weight: bold">{{list.taskName}}</div>
                            <div style="font-size: 12px;">
                                要求：{{list.remarks}}
                            </div>
                        </div>
                        <div class="task-head-two" >
                            <div class="receive-bottom" :class="{'active_style' : list.isReceive != 2 }" v-myclick="[index,receive]">{{itemtype[list.isReceive]}}</div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script src="../../script/components.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript" src="../../script/vant.min.js"></script>

<script>
    var vm,
        wx,
        deliver_list,
        info_list,
    apiready = function () {
        setBSImg();
        new Vue({
            el: '#blank'
        })
        wx = api.require('wx');
        var data = {
            wxOpenId:getPrefs('openid'),
            token:getPrefs('token'),
        };
        var callback  = function(ret){
            deliver_list = ret.content;
            for(var i=0;i<deliver_list.length;i++){
                deliver_list[i].level_task_bg ="../../image/"+getMemberStyleTwo(deliver_list[i].taskLevel).level_task_bg;
            }
            initApp();
            console.log(JSON.stringify(deliver_list))
        };
        pinet.post(APIURLP+'/play/task/giveTaskList', data, callback);
        api.parseTapmode();
    };

    function initApp() {
        // var isBigImg = Vue.BSImg == 'big';
        vm = new Vue({
            el: '#app',
            data: {
                deliver_list:deliver_list,
                itemtype:{
                    '1':'已领取',
                    '2':'领取',
                    '3':'领取',
                },
                info_list:info_list,
            },
            computed: {
            },
            mounted:function(){
              this.get_info();
            },
            methods: {
                get_info:function(){
                    var data = {
                        wxOpenId:getPrefs('openid'),
                        token:getPrefs('token'),
                    };
                    var callback  = function(ret){
                        vm.info_list = ret.content;
                        console.log(JSON.stringify(vm.info_list))
                    };
                    pinet.post(APIURLP+'/play/user/queryUserInfo', data, callback);
                },
                receive:function(value){
                    console.log(vm.deliver_list[value].taskId)
                    if(vm.deliver_list[value].isReceive == 2){
                        var data= {
                            wxOpenId:getPrefs('openid'),
                            token:getPrefs('token'),
                            taskId:vm.deliver_list[value].taskId,
                        };
                        var callback  = function(ret){
                            console.log(JSON.stringify(ret))
                            api.toast({
                                msg: '领取成功',
                                duration: 2000,
                                location: 'middle'
                            });
                            vm.relode();
                        };
                        pinet.post(APIURLP+'/play/task/exeGiveTask', data, callback);
                    }
                },
                relode:function(){
                    var data = {
                        wxOpenId:getPrefs('openid'),
                        token:getPrefs('token'),
                    };
                    var callback  = function(ret){
                        vm.deliver_list = ret.content;
                        for(var i=0;i<vm.deliver_list.length;i++){
                            vm.deliver_list[i].level_task_bg ="../../image/"+getMemberStyleTwo(vm.deliver_list[i].taskLevel).level_task_bg;
                        }
                        console.log(JSON.stringify(vm.deliver_list))
                    };
                    pinet.post(APIURLP+'/play/task/giveTaskList', data, callback);
                },
                getBg: function (url) {
                    return {
                        backgroundImage:'url(' + url +')'
                    };
                },
            },

        })
    }

</script>

</html>
